<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
export default {
    mixins: [Vue.prototype.$vFN.Mixins.Base, Vue.prototype.$vFN.Mixins.Edit],
    components: {
        SelectImageRadio: async () =>
            Vue.extend(await Vue.prototype.$vFN.Components.Base.SelectImageRadio()),
    },
    data() {
        return {
            appWindow: window,
            form: {
            },
            // 得到所有奖励
            lottery: [],

            // 选择要返回的奖励
            myLottery: [],
            // 回显选择过的奖励名称
            list: [],
            // 数据容器
            dataList: []
        };
    },
    methods: {
        // 
        async getdata() {
            console.log(this.type);
            let res = await this.$vFN.Http.post({
                url: "admin/set/getBase",
            }, window);
            if(res.data.lottery != null) {
                if(this.type == 'yes') {
                    this.dataList = res.data.lottery.winning_reward;
                }else if(this.type == 'no'){
                    this.dataList = res.data.lottery.loser_reward;
                }

                this.dataList.forEach(item => {
                    this.myLottery.push(item);
                    this.list.push(item.name)
                });
            }
            
        },
        // 确定后返回的数据
        sum() {
            this.mixinEdit_editVisible = false;
            this.onSuccess(this.myLottery);
        },
        // 选择资产操作
        select(item, index) {
            if(this.type == 'select') {
                this.list = [item.name];
                this.myLottery = [item];
            }else {
                this.list.push(item.name);
                this.myLottery.push(item);
            }
            
        },
        // 获取资产
        async welfare() {
            if(this.type == 'select') {
                // 要扣除的
                let res = await this.$vFN.Http.post({
                    url: "admin/set/getCostIntegral",
                }, window);
                this.lottery = res.data;
            }else {
                // 抽中会员/未抽中会员奖励
                let res = await this.$vFN.Http.post({
                    url: "admin/active/teamCanSelect",
                }, window);
                this.lottery = res.data;
            }
            
        },
        // 初始化
        async init() {
            this.getdata();
            
            this.welfare();
            // 显示窗口
            this.mixinEdit_editVisible = true;
        },
        cacel() {
            this.mixinEdit_editVisible = false;
        },
        onSuccess() {

        },

    },
    mounted() {
        this.init();
    },
    activated() {},
};
</script>